import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const investApi = createApi({
  reducerPath: "investApi",
  baseQuery: fetchBaseQuery({
    baseUrl: "http://localhost:5085",
  }),
  endpoints: (builder) => ({
    getAccount: builder.mutation({
      query: (token) => ({
        url: "/auth",
        headers: {
          Authorization: `Bearer ${token}`,
        },
        method: "POST",
      }),
    }),

    getPortfolio: builder.query({
      query: (id) => ({
        url: `/portfolio/${id}`,
        headers: {
          Authorization: `Bearer ${localStorage.getItem("accessToken")}`,
        },
      }),
    }),

    getSurpise: builder.query({
      query: () => ({
        url: `/surprise`,
        headers: {
          Authorization: `Bearer ${localStorage.getItem("accessToken")}`,
        },
      }),
    }),

    getStrategy: builder.query({
      query: (id) => ({
        url: `/strategy/${id}`,
        headers: {
          Authorization: `Bearer ${localStorage.getItem("accessToken")}`,
        },
      }),
    }),

    getAdvice: builder.query({
      query: (id) => ({
        url: `/advice/${id}`,
        headers: {
          Authorization: `Bearer ${localStorage.getItem("accessToken")}`,
        },
      }),
    }),
  }),
});

export const {
  useGetAccountMutation,
  useGetPortfolioQuery,
  useLazyGetSurpiseQuery,
  useLazyGetStrategyQuery,
  useLazyGetAdviceQuery
} = investApi;
